<%@ page language="java" pageEncoding="utf-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
  <head>
    <html:base />
    
    <title>product_form.jsp</title>

	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  <script  type="text/javascript">
    var xmlhttp =null;
    function  updateProduct(){
      var url="../service/UpdateProduct";
     // var url="http://59.79.57.140:8080/MyRestoraunt/service/UpdateProduct";
      var productName=document.getElementById("productName").value;
      var price=document.getElementById("price").value;
      var Id=document.getElementById("id").value;
      var t;
     // var t=document.getElementById("serial");
    //  var serial=t.options[t.selectedIndex].value;
      t=document.getElementById("state");
      var state=t.options[t.selectedIndex].value;
      t=document.getElementById("recommend");
      var recommend=t.options[t.selectedIndex].value;
       t=document.getElementById("onIndex");
      var onIndex=t.options[t.selectedIndex].value;
       //alert(zone);
     //url+=("?productName="+productName);
       var params="productName="+encodeURIComponent(encodeURIComponent(productName));
      params+="&price="+price;
      
      params+="&state="+state;
      params+="&recommend="+recommend;
      params+="&onIndex="+onIndex;
      params+="&id="+Id;
      url=url+"?"+params;
      alert(url);
      get(url,modifyProductCallback);
     }
     
     function get(url,callback){
        
        if(window.ActiveXObject){
           xmlhttp=new ActiveXObject("Microsoft.XMLHttp");
        }else if(window.XMLHttpRequest){
           xmlhttp=new XMLHttpRequest();  
        } 
        xmlhttp.open("POST", url, false);
        xmlhttp.onreadystatechange = callback;
        xmlhttp.send();
       
      }
      
     function modifyProductCallback(){
      if(xmlhttp.readyState==4){
         if(xmlhttp.status==200){
            alert("修改成功");
         }else{
            alert("修改失败");
         }
      }
      }
      
    </script>
  <body> 
  <input type="hidden" id="id" value="${product.id}">
    产品名称: <input type="text" maxlength="25" size="15" name="productName"  id="productName" value="${product.name}"><br>
    产品价格:<input type="text" maxlength="25" size="15" name="price" id="price" value="${product.price}"><br>
    <!-- 产品类别：<select size="1" name="serial" id="serial"></select><br> -->
    是否上线:<select size="1" name="state" id="state">
    <logic:equal value="0" name="product" property="state">  <option selected value="0">上线</option> <option value="1">下线</option></logic:equal> 
    <logic:equal value="1" name="product" property="state">  <option  value="0">上线</option> <option selected value="1">下线</option></logic:equal> 
       </select><br>
      是否推荐:<select size="1" name="recommend" id="recommend">
     <logic:equal value="1" name="product" property="onRecommend"> <option selected value="1">推荐</option>  <option value="0">不推荐</option></logic:equal> 
     <logic:equal value="0" name="product" property="onRecommend"> <option  value="1">推荐</option>  <option  selected value="0">不推荐</option></logic:equal> 
</select><br>首页项：<select size="1" name="onIndex" id="onIndex">
    <logic:equal value="0" name="product" property="onIndex"> <option selected value="0">否</option><option value="1">是</option></logic:equal> 
    <logic:equal value="1" name="product" property="onIndex"> <option value="0">否</option><option selected value="1">是</logic:equal>
</select>
<br><input type="button" value="确定修改" name="submit" onclick="updateProduct()">




  </body>
</html:html>
